package com.huatai.model.config;

/**
 *  树节点配置类
 * @author yukun
 * @Date 2020/4/21 16:23
 * @param
 * @return
 * @package
 */
public class TreeNodeConfig {

    /**
     * 默认属性的单例对象
     */
    private static TreeNodeConfig defaultConfig = new TreeNodeConfig();

    /**
     * 树节点默认属性常量
     */
    static final String TREE_ID = "id";
    static final String TREE_NAME = "title";
    static final String TREE_CODE = "code";
    static final String TREE_CHILDREN = "children";
    static final String TREE_PARENT_ID = "parentId";
    static final String TREE_TYPE = "type";


    private String idKey;
    private String codeKey;
    private String nameKey;
    private String childrenKey;
    private String parentIdKey;
    private String typeKey;

    public String getTypeKey() {
        return getOrDefault(typeKey,TREE_TYPE);
    }

    public void setTypeKey(String typeKey) {
        this.typeKey = typeKey;
    }

    public String getIdKey() {
        return getOrDefault(idKey,TREE_ID);
    }

    public void setIdKey(String idKey) {
        this.idKey = idKey;
    }

    public String getCodeKey() {
        return getOrDefault(codeKey,TREE_CODE);
    }

    public void setCodeKey(String codeKey) {
        this.codeKey = codeKey;
    }

    public String getNameKey() {
        return getOrDefault(nameKey,TREE_NAME);
    }

    public void setNameKey(String nameKey) {
        this.nameKey = nameKey;
    }

    public String getChildrenKey() {
        return getOrDefault(childrenKey,TREE_CHILDREN);
    }

    public void setChildrenKey(String childrenKey) {
        this.childrenKey = childrenKey;
    }

    public String getParentIdKey() {
        return getOrDefault(parentIdKey,TREE_PARENT_ID);
    }

    public void setParentIdKey(String parentIdKey) {
        this.parentIdKey = parentIdKey;
    }

    public String getOrDefault(String key,String defaultKey){
        if(key == null) {
            return defaultKey;
        }
        return key;
    }

    public static TreeNodeConfig getDefaultConfig(){
        return defaultConfig;
    }
}
